package com.springboot2.validate.vo;

import com.springboot2.validate.annotation.DateTime;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
@AllArgsConstructor // 自动生成全参构造函数
@NoArgsConstructor
public class StudentVO implements Serializable {

    /**
     * 学号，不允许为空字符串也不允许为空
     */
    @NotBlank(message = "学号不允许为空")
    @NotNull(message = "学号不允许为空")
    @Length(min = 6, max = 34, message = "学号长度必须在 {min} 到 {max} 之间")
    private String studentNo;

    /**
     * 学生姓名，不允许为空字符串也不允许为空
     */
    @NotBlank(message = "学生姓名不允许为空")
    @NotNull(message = "学生姓名不允许为空")
    @Length(min = 2, max = 128, message = "学生名字长度必须在 {min} 到 {max} 之间")
    private String name;

    @Max(value = 380, message = "年龄不能大于 {value}")
    private Short age;

    private String gender;

    @DateTime(message = "时间日期格式不正确", formatter = "yyyy-MM-dd hh:mm:ss")
    private String createTime;
}
